<template>
    <div>
        <TopBar title="更新工单（开发测试用）" iconshow></TopBar>
        <van-form @submit="onSubmit">
            <van-field
                v-model="id"
                name="工单id"
                label="工单id"
                placeholder="工单id"
                :rules="[{ required: true, message: '请填写工单id' }]"
            />
            <van-field
                v-model="form.line"
                name="厂线号"
                label="厂线号"
                placeholder="厂线号"
                :rules="[{ required: true, message: '请填写厂线号' }]"
            />
            <van-field
                v-model="form.device"
                name="设备号"
                label="设备号"
                placeholder="设备号"
                :rules="[{ required: true, message: '请填写设备号' }]"
            />
            <van-field
                v-model="form.submitor"
                name="提交人"
                label="提交者工号"
                placeholder="提交人"
                :rules="[{ required: true, message: '请填写提交者工号' }]"
            />
            <van-field
                v-model="form.desp"
                name="描述"
                label="工单描述"
                placeholder="描述"
                :rules="[{ required: true, message: '请填写工单描述' }]"
            />
            <van-field
                v-model="form.type"
                name="工单类型"
                label="工单类型"
                placeholder="工单类型"
                :rules="[{ required: true, message: '请填写工单类型' }]"
            />
            <van-field
                v-model="form.status"
                name="工单状态"
                label="工单状态"
                placeholder="工单状态"
                :rules="[{ required: true, message: '请填写工单状态' }]"
            />
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit" style="display: inline">提交</van-button>
            </div>
        </van-form>
    </div>
</template>

<script>
import TopBar from "@/components/TopBar";

export default {
    // eslint-disable-next-line vue/multi-word-component-names
    name: "updateForm",
    data() {
        return {
            id: '',  //工单Id
            form: {
                line: '',
                device: '',  //设备Id
                submitor: '',
                desp: '',
                status: null,   //工单状态
                type: null,  //工单类型
            }
        };
    },

    components: {
        TopBar,
    },

    methods: {
        clear() {
            this.$router.push('/etc')
        },
        onSubmit() {
            this.$axios({
                method: 'put',
                url: 'http://47.97.219.99:8018/cloudForm/updateFormById',
                params: {
                    form: JSON.stringify(this.form),
                    id: this.id
                },
                headers: {'content-type': 'x-www-form-urlencoded'},
            })
            this.clear();
            this.$store.dispatch('asyncUpdataDeviceSheet', this.form.device, this.id)
        }
    }
}
</script>

<style scoped>

</style>
